#define INLINE inline
+#define LSHIFT 2
typedef float (* BablLookupFunction) (float value,
void *data);
BablLookupFunction function;
void *data;
int shift;
- unsigned int positive_min, positive_max, negative_min, negative_max;
- unsigned int bitmask[babl_LOOKUP_MAX_ENTRIES/32];
+ uint32_t positive_min, positive_max, negative_min, negative_max;
+ uint32_t bitmask[babl_LOOKUP_MAX_ENTRIES/32];
float table[];
} BablLookup;
union
{
float f;
- unsigned int i;
+ uint32_t i;
} u;
- unsigned int i;
+ uint32_t i;
u.f = number;
- i = u.i >> lookup->shift;
+ i = (u.i << LSHIFT )>> lookup->shift;
if (i > lookup->positive_min &&
i < lookup->positive_max)
if (!(lookup->bitmask[i/32] & (1<<(i & 31))))
{
+ /* XXX: should look up the value in the middle of the range
+ * that yields a given value,
+ *
+ * potentially even do linear interpolation between
+ * the two neighbour values to get away with a tiny
+ * lookup table..
+ */
lookup->table[i]= lookup->function (number, lookup->data);
lookup->bitmask[i/32] |= (1<<(i & 31));
}
union
{
float f;
- unsigned int i;
+ uint32_t i;
} u;
int positive_min, positive_max, negative_min, negative_max;
int shift;
if (end < 0.0)
{
u.f = start;
- positive_max = u.i >> shift;
+ positive_max = (u.i << LSHIFT) >> shift;
u.f = end;
- positive_min = u.i >> shift;
+ positive_min = (u.i << LSHIFT) >> shift;
negative_min = positive_max;
negative_max = positive_max;
}
else
{
u.f = 0 - precision;
- positive_min = u.i >> shift;
+ positive_min = (u.i << LSHIFT) >> shift;
u.f = start;
- positive_max = u.i >> shift;
+ positive_max = (u.i << LSHIFT) >> shift;
u.f = 0 + precision;
- negative_min = u.i >> shift;
+ negative_min = (u.i << LSHIFT) >> shift;
u.f = end;
- negative_max = u.i >> shift;
+ negative_max = (u.i << LSHIFT) >> shift;
}
}
else
{
u.f = start;
- positive_min = u.i >> shift;
+ positive_min = (u.i << LSHIFT) >> shift;
u.f = end;
- positive_max = u.i >> shift;
+ positive_max = (u.i << LSHIFT) >> shift;
negative_min = positive_max;
negative_max = positive_max;
}